Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Can't click "I am agree" button in Selenium with NodeJS

I try to write an automatic test in Selenium with NodeJS and I have a little problem.

First of all, my code:

const {Builder, By, Key, until} = require("selenium-webdriver");
async function example() {
    let driver = await new Builder().forBrowser('chrome').build();
    await driver.get('http://www.google.com');
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
  
}

example();

Every time i start my app with "node index", a new chrome/firefox app is opening and asking me if I am agree with cookies. I tried to go to settings or to connect my account and allow cookies anytime but if I start again my app, my settings are gone.

I think the solution is to click manually that "I am Agree" button with my code but I don't know how to do this. Can anybody help me, please?

How should I write the code to can click that agree button or what else I should try?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To click on I agree use the following xpath to identify the element

await driver.findElement(By.xpth('//div[text()="I agree"]')).click()

Your code will be

const {Builder, By, Key, until} = require("selenium-webdriver");
async function example() {
    let driver = await new Builder().forBrowser('chrome').build();
    await driver.get('http://www.google.com');
    await driver.findElement(By.xpth('//div[text()="I agree"]')).click();
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
  
}

example();
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda